package com.suncaper.han_yi_system.controller;

import com.suncaper.han_yi_system.result.Result;
import com.suncaper.han_yi_system.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private FileService fileService;

    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {
        Map upload = fileService.upload(file);
        return Result.ok().data(upload);
    }
}
